<template>
	<!-- 用户收入管理子组件 -->
  <div class="stu">
	 <el-dialog v-loading="loading"  :title="num==1?'编辑医疗保障信息':'新增医疗保障信息'" :visible.sync="dialogVisible" width="35%" :before-close="handleClose" :close-on-click-modal='false'>
	   <!-- <p class="pbox" style="text-align: center;width:100%;font-size:30px;height:40px;">员工信息详情</p> -->
	    <div style="width:100%;padding-bottom:20px;">
			
			<div style="margin-top:10px;" class="tabbox">
					<p style="width:15%;"><a style="color:red;">* </a>姓名</p>
					<el-input style='width:75%;' placeholder="请输入" v-model="activess.name" clearable></el-input>
			</div>
			<div style="margin-top:10px;" class="tabbox">
					<p style="width:15%;"><a style="color:red;">* </a>身份证号</p>
					<el-input style='width:75%;' placeholder="请输入" v-model="activess.card" clearable></el-input>
			</div>
			<div style="margin-top:10px;" class="tabbox">
					<p style="width:15%;"><a style="color:red;">* </a>一卡通账号</p>
					<el-input style='width:75%;' placeholder="请输入" v-model="activess.account" clearable></el-input>
			</div>
			<div style="margin-top:10px;" class="tabbox">
					<p style="width:15%;"><a style="color:red;">* </a>交易时间</p>
					<el-date-picker  style='width:75%;' v-model="activess.deal_date" type="date" value-format='yyyy-MM-dd' placeholder="选择日期"></el-date-picker>
			</div>
			<div style="margin-top:10px;" class="tabbox">
					<p style="width:15%;"><a style="color:red;">* </a>交易金额</p>
					<el-input style='width:75%;' placeholder="请输入" type='number' min='0' v-model="activess.deal_money" clearable>
						<template slot="append">￥</template>
					</el-input>
			</div>
			<div style="margin-top:10px;" class="tabbox">
					<p style="width:15%;"><a style="color:red;">* </a>账户余额</p>
					<el-input style='width:75%;' placeholder="请输入" type='number' min='0' v-model="activess.account_money" clearable>
						<template slot="append">￥</template>
					</el-input>
			</div>
			<div style="margin-top:10px;" class="tabbox">
					<p style="width:15%;"><a style="color:red;">* </a>资金类型</p>
					<el-input style='width:75%;' placeholder="请输入" v-model="activess.comment" clearable></el-input>
			</div>
			
		</div>	
		<div style="width:100%;height:40px;margin-top:20px;">
	      <div style="width:170px;margin: 0 auto;">
	        <el-button type="danger" @click="handleClose">取 消</el-button>
	        <el-button type="primary" style='float:right;' @click="git_acts">确 定</el-button>
	      </div>
		</div>
	 </el-dialog>
	
  </div>
</template>

<script>
import $ from 'jquery'
export default {
  name: 'stu',
  components: {},//声明子组件
  computed:{
	  
  },
  data(){
	  return {
		loading:false,
		btn_shou:false,
		dialogVisible: false,
		activess:{
			 name:'',//姓名
			 	   card:'',//身份证号码
			 	   account:'',//一卡通账号
			 	   deal_date:'',//交易时间(日期)
			 	   deal_money:'',//交易金额
			 	   account_money:'',//账户余额
			 	   comment:'',//资金类型(纯中文)
			 	   id:'',//主键
		},
		
		renbox:[],
		num:0,
	  }
  },
  methods:{
	  git_act(i,num){//获取数据的同打开狂口
	      if(num==1){
			  this.activess = i;
			  // this.activess.is_out = this.activess.is_out+'';
		  }
		  this.num = num;
	      console.log(this.activess,num);
	      this.dialogVisible=true;
	  },
	  git_acts(){//提交数据
	        console.log(this.activess);
			if(this.isNull(this.activess.name)){this.$message.error('请输入 姓名');return false}
			if(this.isNull(this.activess.card)){this.$message.error('请输入 身份证号');return false}
			if(this.iscard(this.activess.card)){this.$message.error('身份证号格式不正确');return false}
			if(this.isNull(this.activess.account)){this.$message.error('请输入 一卡通账号');return false}
	        if(this.isNull(this.activess.deal_date)){this.$message.error('请选择 交易时间');return false}
	  		if(this.activess.deal_money){}else{this.$message.error('请输入 交易金额');return false}
			if(this.activess.deal_money<0){this.$message.error('交易金额不能小于零');return false}
			if(this.activess.account_money){}else{this.$message.error('请输入 账户余额');return false}
			if(this.activess.account_money<0){this.$message.error('账户余额不能小于零');return false}
			if(this.isNull(this.activess.comment)){this.$message.error('请输入 资金类型');return false}
			
	  		 let url = this.num==1?'/dj/user_manage/poor_income_modify':'/dj/user_manage/poor_income_insert';
	  		 $.ajax({url:url,type:'post',data:this.activess,dataType:'json',success:(res)=> {
	  		 	if(Object.prototype.toString.call(res) != '[object Object]'){res = JSON.parse(res)}
	  		 	 console.log(res,'提交');
	  		 	 if(res.code==200){
	  				this.$parent.git_act();
	  		 		this.$message({message: '操作成功',type: 'success'});
	  		 		this.dialogVisible=false;
	  				this.qin();
	  		 	  }else{
	  		 		 this.$message.error(res.msg);
	  		 	  }
	  		 	}
	  		 })
	  },
	  qin(){//清除
	  	this.activess={
			 name:'',//姓名
			 	   card:'',//身份证号码
			 	   account:'',//一卡通账号
			 	   deal_date:'',//交易时间(日期)
			 	   deal_money:'',//交易金额
			 	   account_money:'',//账户余额
			 	   comment:'',//资金类型(纯中文)
			 	   id:'',//主键
		}
	  },
	  
	  handleClose(done){//监测用户点击x
	     this.$confirm('确定取消关闭吗？','提示',{confirmButtonText:'确定',cancelButtonText:'取消',type: 'warning'}).then(() => {
	  	   this.dialogVisible = false;
	  	   this.qin();
		   this.$parent.git_act();
	  	}).catch(() => {});
	  },
	  
  },
  mounted(){
	  // this.git_ren()
  }
}
</script>
<style scoped="scoped">
	
	.pboxc1{
		float:left;
		width:70%;
		height:40px;
		border:1px solid rgba(242,242,242,1);
		font-size:14px;color:#666666;
		/* padding-left:18px; */
		text-align:left;
		/* overflow: hidden; */
		/* text-overflow:ellipsis; */
		/* white-space: nowrap; */
	}
	.tabbox{
		width:100%;
		height:40px;
		line-height: 30px;
		margin-top:23px;
	}
	.tabbox p{
		font-size:14px;
		color:#000000;
		width:19.5%;
		text-align:right;
		margin-right:28px;
		float:left;
		overflow: hidden;
		text-overflow:ellipsis;
		white-space: nowrap;
		font-family:Source Han Sans CN;
	}
	.pbox{
		width:10%;
		text-align:right;
		height:26px;
		margin-bottom:20px;
		font-size:18px;
		color:#000101;
		overflow: hidden;
		text-overflow:ellipsis;
		white-space: nowrap;
		font-family:Source Han Sans CN;
		font-weight:600;
	}
</style>
